
<script setup>
import { onMounted, ref } from 'vue';
import { ElMessage } from 'element-plus';
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/module/user'
import { useRoute } from 'vue-router';

const route = useRoute();
const router = useRouter()
const userStore = useUserStore();
const id=route.query.id;

const activeMenu = ref('my');

// 导航栏点击事件
const handleMenuSelect = (index) => {
  switch(index) {
    case 'find':
      router.push('/headYes/partner/find');
      break;
    case 'my':
      router.push('/headYes/partner/my');
      break;
    case 'group':
      router.push('/headYes/partner/study');
      break;
    case 'question':
      router.push('/headYes/partner/question');
      break;
  }
};

const goToPersonalCenter = () => {
  router.push('/user/UserInformation')
};
//默认进入是找伙伴页面
onMounted(() => {
  if(id!=4){
    router.push('/headYes/partner/my');
  }else
  {
    activeMenu.value = 'question';
    router.push('/headYes/partner/question');
  }
})


// 这些方法可以保留或移除，根据实际需要
</script>
<template>
  <div class="app-container">
    <!-- 顶部导航栏 -->
    <el-header class="header">
      <div class="header-content">
        <div class="logo">学伴</div>
        <el-menu
          :default-active="activeMenu"
          class="nav-menu"
          mode="horizontal"
          @select="handleMenuSelect"
        >
          <el-menu-item index="my">我的伙伴</el-menu-item>
          <el-menu-item index="find">找伙伴</el-menu-item>
          <el-menu-item index="group">学习小组</el-menu-item>
          <el-menu-item index="question">问答</el-menu-item>
        </el-menu>
        <div class="auth-area">
          <el-button type="success" @click="goToPersonalCenter" class="auth-area-button" >个人中心</el-button>
          <el-avatar :src="userStore.avatar" class="avatar" />
        </div>
      </div>
    </el-header>

    <!-- 主内容区：增加高度 -->
    <el-main class="main">
      <div class="main-content">
        <router-view></router-view>
      </div>
    </el-main>

    <!-- 页脚区域：适当增加高度 -->
    <el-footer class="footer">
      <div class="footer-content">
        <p>© 2023 学伴 - 找到你的最佳学习搭档</p>
        <p>联系我们 | 使用帮助 | 隐私政策</p>
      </div>
    </el-footer>
  </div>
</template>



<style scoped>
/* 根容器样式 */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-top: 30px;

}

/* 顶部导航栏：保持原有高度 */
.header {
  background-color: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  height: 70px; /* 略微增加导航栏高度 */
  padding: 0;
  position: fixed; /* 固定在视口 */
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}
.header-content {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 100%;
}
.logo {
  font-size: 40px;
  font-weight: bold;
  color: #27ae60;
  margin-right: 10px;
  margin-left: 50px;

  font-family: "Ma Shan Zheng", "KaiTi", serif;
  font-size: 52px;
  letter-spacing: 10px;

}
.nav-menu {
  flex: 1;
  margin: 0 40px;
}
.auth-area {
  display: flex;
  align-items: center;
}
.auth-area-button {
  /* 绿色圆角边框 */
  border: 1px solid #27ae60;
  /* 边框圆角加大 */
  border-radius: 20px;
  width: 100px; /* 按钮宽度 */
  height: 40px; /* 按钮高度 */
  /* 字体变大 */
  font-size: 16px;
}
.avatar {
  margin-left: 10px;
  cursor: pointer;
  width: 42px; /* 增大头像 */
  height: 42px;
}

/* 主内容区：显著增加高度 */
.main {
  flex: 1;
  background-color: #e6f7ef;
  /* padding: 40px 0; */
  min-height: 600px; /* 设置最小高度，确保内容区足够高 */
}
.main-content {
  width: 100%;
  max-width: 2300px;
  margin: 0 auto;
  /* padding: 0 20px; */
}

/* 页脚区域：适当增加高度 */
.footer {
  background-color: #e6f7ef;
  /* padding: 20px 0; */

  margin-bottom: 10px; /* 增加底部间距，提升整体高度 */
}
.footer-content {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
  text-align: center;
  color: #666;
  font-size: 14px;
}
.footer-content p {
  margin-bottom: 8px; /* 增加行间距 */
}
.footer-content p:last-child {
  margin-bottom: 0;
}
</style>
